﻿<views:UserControlBase x:Class="GoG.Client.Views.ChatUserControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:views="using:GoG.Client.Views"
             xmlns:chat="using:GoG.Client.ViewModels.Chat"
             mc:Ignorable="d"
             d:DataContext="{d:DesignInstance chat:ChatViewModel, IsDesignTimeCreatable=True}"
			 d:DesignHeight="300"
			 d:DesignWidth="400">

    <UserControl.Resources>
        <Style x:Key="SimpleListViewItemStyle" TargetType="ListViewItem">
            <Setter Property="Background" Value="Transparent"/>
            <Setter Property="Margin" Value="0"/>
            <Setter Property="TabNavigation" Value="Local"/>
            <Setter Property="IsHoldingEnabled" Value="False"/>
            <Setter Property="IsDoubleTapEnabled" Value="False"/>
            <Setter Property="IsRightTapEnabled" Value="False" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="ListViewItem">
                        <Border BorderBrush="{TemplateBinding BorderBrush}" 
                                BorderThickness="{TemplateBinding BorderThickness}" 
                                Background="{TemplateBinding Background}" 
                                Margin="0">

                            <VisualStateManager.VisualStateGroups>
                                <VisualStateGroup x:Name="CommonStates">
                                    <VisualState x:Name="Normal"/>
                                    <VisualState x:Name="Pressed">
                                        <!--<Storyboard>
                                            <PointerDownThemeAnimation TargetName="Container"/>
                                        </Storyboard>-->
                                    </VisualState>
                                </VisualStateGroup>
                            </VisualStateManager.VisualStateGroups>

                            <Grid x:Name="Container">
                                <ContentPresenter x:Name="contentPresenter" 
                                                  ContentTemplate="{TemplateBinding ContentTemplate}" 
                                                  ContentTransitions="{TemplateBinding ContentTransitions}" 
                                                  Content="{TemplateBinding Content}" 
                                                  HorizontalAlignment="Stretch" 
                                                  Margin="0" 
                                                  VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
                            </Grid>
                        </Border>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </UserControl.Resources>
    
    <!-- Page content -->
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="*"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*"/>
            <ColumnDefinition Width="Auto"/>
        </Grid.ColumnDefinitions>

        <ListView ItemsSource="{Binding Items}"
                  Grid.Row="0"
                  Grid.ColumnSpan="2"
                  SelectionMode="None" IsItemClickEnabled="False"
                  ScrollViewer.VerticalScrollBarVisibility="Hidden"
                  ScrollViewer.HorizontalScrollBarVisibility="Hidden"
                  ItemContainerStyle="{StaticResource SimpleListViewItemStyle}"
                  IsHitTestVisible="False">
            <ListView.ItemTemplate>
                <DataTemplate>
                    <Grid VerticalAlignment="Center"
                          Background="#16000000">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="130" />
                            <ColumnDefinition Width="*" />
                        </Grid.ColumnDefinitions>

                        <TextBlock Grid.Column="0" Margin="5,0,10,8"
                                   Style="{StaticResource ChatNameStyle}"
                                   Text="{Binding Path=Username}" />

                        <TextBlock Grid.Column="1" Margin="0,0,10,8"
                                   Style="{StaticResource ChatMessageStyle}"
                                   Text="{Binding Path=Message}"/>
                    </Grid>
                </DataTemplate>
            </ListView.ItemTemplate>
        </ListView>
        
        <TextBox Grid.Row="1"
                 IsTextPredictionEnabled="True"
                 Height="1"
                 Text="{Binding Message, Mode=TwoWay}"/>
        
        <Button Grid.Row="1"
                Grid.Column="1"
                Margin="3,0,0,0"
                Content="Send"
                Command="{Binding SendMessageCommand}"/>
    </Grid>
</views:UserControlBase>
